package com.mark.musicbox;

import android.app.ActivityGroup;
import android.app.LocalActivityManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class ActivityModuleMusic extends ActivityGroup implements
		View.OnClickListener {
	LinearLayout contain = null;
	ImageView tabMusic = null;
	ImageView tabList = null;
	LocalActivityManager m = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.module_music);
		contain = (LinearLayout) findViewById(R.id.musicContain);
		tabMusic = (ImageView) findViewById(R.id.tab_Music);
		tabList = (ImageView) findViewById(R.id.tab_List);
		m = getLocalActivityManager();
		tabMusic.setOnClickListener(this);
		tabList.setOnClickListener(this);
		Intent intent = new Intent();
		intent.setClass(ActivityModuleMusic.this, ActivityMusicList.class);
		Window w = m.startActivity("containActivity1", intent);
		contain.removeAllViews();
		contain.addView(w.getDecorView());
	}

	public void onClick(View v) {
		Intent intent = new Intent();
		switch (v.getId()) {
		case R.id.tab_Music:
			tabMusic.setImageResource(R.drawable.top_tab_music_default);
			tabList.setImageResource(R.drawable.top_tab_list_press);
			intent.setClass(ActivityModuleMusic.this, ActivityMusicList.class);
			Window w = m.startActivity("containActivity1", intent);
			contain.removeAllViews();
			contain.addView(w.getDecorView());
			break;
		case R.id.tab_List:
			tabMusic.setImageResource(R.drawable.top_tab_music_press);
			tabList.setImageResource(R.drawable.top_tab_list_default);
			intent.setClass(ActivityModuleMusic.this, ActivityMusicList.class);
			w = m.startActivity("containActivity1", intent);
			contain.removeAllViews();
			contain.addView(w.getDecorView());
			break;
		}
	}
}
